package jagex.client;

public class Menu {

	public Menu(GameImage arg0, int arg1) {
		currentFocusHandle = -1;
		bg = true;
		gameImage = arg0;
		oe = arg1;
		menuObjectCanAcceptActions = new boolean[arg1];
		qe = new boolean[arg1];
		re = new boolean[arg1];
		se = new boolean[arg1];
		menuObjectColourMask = new boolean[arg1];
		te = new boolean[arg1];
		ue = new int[arg1];
		menuListTextCount = new int[arg1];
		we = new int[arg1];
		xe = new int[arg1];
		menuObjectX = new int[arg1];
		menuObjectY = new int[arg1];
		menuObjectType = new int[arg1];
		menuObjectWidth = new int[arg1];
		menuObjectHeight = new int[arg1];
		handleMaxTextLength = new int[arg1];
		menuObjectTextType = new int[arg1];
		menuObjectText = new String[arg1];
		menuListText = new String[arg1][];
		
		/*
		 * Colors
		 * Need to figure out how they are used and better names for them.
		 * I have seen these colors before on the original website. Must be themed. 
		 * TODO - need proper names and logging.
		 */
		jagexColorPink = convertRGBToLongWithModifier(114, 114, 176); //pink/purple
		jagexColorDarkBlue = convertRGBToLongWithModifier(14, 14, 62); //Dark Blue
		jagexColorWhiteBlue = convertRGBToLongWithModifier(200, 208, 232); //white with faint blue
		jagexColorTealBlue = convertRGBToLongWithModifier(96, 129, 184); // light blue
		jagexColorDarkGreen = convertRGBToLongWithModifier(53, 95, 115); //dark greenish
		jagexColorGrayBlue = convertRGBToLongWithModifier(117, 142, 171);
		jagexColorGrayTeal = convertRGBToLongWithModifier(98, 122, 158);
		jagexColorDarkPurple = convertRGBToLongWithModifier(86, 100, 136); //hex code 566488
		COLOUR_BOX_GRADIENT_TOP = convertRGBToLongWithModifier(135, 146, 179);
		COLOUR_BOX_GRADIENT_BOTTOM = convertRGBToLongWithModifier(97, 112, 151); //purple/blue
		COLOUR_BOX_BORDER1 = convertRGBToLongWithModifier(88, 102, 136); //lighter purple
		COLOUR_BOX_BORDER2 = convertRGBToLongWithModifier(84, 93, 120); //purple gray
	}

	public int convertRGBToLongWithModifier(int red, int green, int blue) {
		return GameImage.convertRGBtoLong((redModifier * red) / 114, (greenModifier * green) / 114, (blueModifier * blue) / 176);
	}

	public void bd(int arg0) {
		menuObjectCanAcceptActions[arg0] = true;
	}

	public void nd(int arg0) {
		menuObjectCanAcceptActions[arg0] = false;
	}

	public void kd() {
		lastMouseButton = 0;
	}

	public void md(int arg0, int arg1, int arg2, int arg3) {
		mouseX = arg0 - nf;
		mouseY = arg1 - of;
		lf = arg3;
		if (arg2 != 0) {
			lastMouseButton = arg2;
		}
		if (arg2 == 1) {
			for (int j = 0; j < menuObjectCount; j++) {
				if (menuObjectCanAcceptActions[j] && menuObjectType[j] == 10 && mouseX >= menuObjectX[j] && mouseY >= menuObjectY[j]
						&& mouseX <= menuObjectX[j] + menuObjectWidth[j] && mouseY <= menuObjectY[j] + menuObjectHeight[j]) {
					se[j] = true;
				}
			}

		}
	}

	public boolean hasActivated(int arg0) {
		if (menuObjectCanAcceptActions[arg0] && se[arg0]) {
			se[arg0] = false;
			return true;
		} else {
			return false;
		}
	}

	public void keyDown(int key) {
		if (key == 0) {
			return;
		}
		if (currentFocusHandle != -1 && menuObjectText[currentFocusHandle] != null && menuObjectCanAcceptActions[currentFocusHandle]) {
			int textLength = menuObjectText[currentFocusHandle].length();
			if (key == 8 && textLength > 0) {
				menuObjectText[currentFocusHandle] = menuObjectText[currentFocusHandle].substring(0, textLength - 1);
			}
			if ((key == 10 || key == 13) && textLength > 0) {
				se[currentFocusHandle] = true;
			}
			String validCharSetup = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";
			if (textLength < handleMaxTextLength[currentFocusHandle]) {
				for (int k = 0; k < validCharSetup.length(); k++) {
					if (key == validCharSetup.charAt(k)) {
						menuObjectText[currentFocusHandle] += (char) key;
					}
				}

			}
			te[currentFocusHandle] = true;
			if (key == 9) {
				do { currentFocusHandle = (currentFocusHandle + 1) % menuObjectCount;
				} while (menuObjectType[currentFocusHandle] != 5 && menuObjectType[currentFocusHandle] != 6);
				te[currentFocusHandle] = true;
			}
		}
	}

	public void lc(int arg0) {
		currentFocusHandle = arg0;
	}

	public void tc(int arg0, int arg1, int arg2, int arg3) {
		if (cg) {
			gameImage.setDimensions(arg0, arg1, arg2, arg3);
			for (int j = 0; j < menuObjectCount; j++) {
				if (menuObjectCanAcceptActions[j]) {
					if (menuObjectType[j] == 0) {
						drawTextAddHeight(j, menuObjectX[j], menuObjectY[j], menuObjectText[j], menuObjectTextType[j]);
					} else if (menuObjectType[j] == 1) {
						drawTextAddHeight(j, menuObjectX[j] - gameImage.textWidth(menuObjectText[j], menuObjectTextType[j]) / 2, menuObjectY[j], menuObjectText[j],
								menuObjectTextType[j]);
					} else if (menuObjectType[j] == 2) {
						ed(menuObjectX[j], menuObjectY[j], menuObjectWidth[j], menuObjectHeight[j]);
					} else if (menuObjectType[j] == 3) {
						sc(menuObjectX[j], menuObjectY[j], menuObjectWidth[j]);
					} else if (menuObjectType[j] == 11) {
						cd(menuObjectX[j], menuObjectY[j], menuObjectWidth[j], menuObjectHeight[j]);
					} else if (menuObjectType[j] == 12) {
						wc(menuObjectX[j], menuObjectY[j], menuObjectTextType[j]);
					}
				}
			}

			gameImage.resetDimensions();
		}
	}

	public void drawMenu() {
		for (int menuObject = 0; menuObject < menuObjectCount; menuObject++) {
			if (menuObjectCanAcceptActions[menuObject]) {
				if (!cg) {
					if (menuObjectType[menuObject] == 0) {
						drawTextAddHeight(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectText[menuObject], menuObjectTextType[menuObject]);
					} else if (menuObjectType[menuObject] == 1) {
						drawTextAddHeight(menuObject, menuObjectX[menuObject] - gameImage.textWidth(menuObjectText[menuObject], menuObjectTextType[menuObject]) / 2, menuObjectY[menuObject], menuObjectText[menuObject],
								menuObjectTextType[menuObject]);
					} else if (menuObjectType[menuObject] == 2) {
						ed(menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject], menuObjectHeight[menuObject]);
					} else if (menuObjectType[menuObject] == 3) {
						sc(menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject]);
					} else if (menuObjectType[menuObject] == 11) {
						cd(menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject], menuObjectHeight[menuObject]);
					} else if (menuObjectType[menuObject] == 12) {
						wc(menuObjectX[menuObject], menuObjectY[menuObject], menuObjectTextType[menuObject]);
					}
				}
				if (menuObjectType[menuObject] == 4) {
					zc(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject], menuObjectHeight[menuObject], menuObjectTextType[menuObject], menuListText[menuObject], menuListTextCount[menuObject],
							ue[menuObject]);
				} else if (menuObjectType[menuObject] == 5 || menuObjectType[menuObject] == 6) {
					pc(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject], menuObjectHeight[menuObject], menuObjectText[menuObject], menuObjectTextType[menuObject]);
				} else if (menuObjectType[menuObject] == 7) {
					mc(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectTextType[menuObject], menuListText[menuObject]);
				} else if (menuObjectType[menuObject] == 8) {
					zb(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectTextType[menuObject], menuListText[menuObject]);
				} else if (menuObjectType[menuObject] == 9) {
					dc(menuObject, menuObjectX[menuObject], menuObjectY[menuObject], menuObjectWidth[menuObject], menuObjectHeight[menuObject], menuObjectTextType[menuObject], menuListText[menuObject], menuListTextCount[menuObject],
							ue[menuObject]);
				}
			}
		}

		lastMouseButton = 0;
	}

	public int rc(int arg0) {
		return we[arg0];
	}

	public int hc(int arg0) {
		int j = xe[arg0];
		return j;
	}

	protected void drawTextAddHeight(int menuObject, int x, int y, String text, int type) {
		int j = y + gameImage.messageFontHeight(type) / 3;
		drawTextWithMask(menuObject, x, j, text, type);
	}

	protected void drawTextWithMask(int menuObject, int x, int y, String text, int type) {
		int color;
		if (menuObjectColourMask[menuObject]) {
			color = 0xffffff;
		} else {
			color = 0;
		}
		gameImage.drawString(text, x, y, type, color);
	}

	protected void pc(int arg0, int arg1, int arg2, int arg3, int arg4,
			String arg5, int arg6) {
		if (re[arg0]) {
			int j = arg5.length();
			arg5 = "";
			for (int l = 0; l < j; l++) {
				arg5 = arg5 + "X";
			}

		}
		if (menuObjectType[arg0] == 5) {
			if (lastMouseButton == 1 && mouseX >= arg1 && mouseY >= arg2 - arg4 / 2 && mouseX <= arg1 + arg3 && mouseY <= arg2 + arg4 / 2) {
				te[currentFocusHandle] = true;
				te[arg0] = true;
				currentFocusHandle = arg0;
			}
			if (te[arg0]) {
				tc(arg1, arg2 - arg4 / 2, arg1 + arg3, arg2 + arg4 / 2);
				te[arg0] = false;
			}
		} else if (menuObjectType[arg0] == 6) {
			if (lastMouseButton == 1 && mouseX >= arg1 - arg3 / 2 && mouseY >= arg2 - arg4 / 2
					&& mouseX <= arg1 + arg3 / 2 && mouseY <= arg2 + arg4 / 2) {
				te[currentFocusHandle] = true;
				te[arg0] = true;
				currentFocusHandle = arg0;
			}
			if (te[arg0]) {
				tc(arg1 - arg3 / 2, arg2 - arg4 / 2, arg1 + arg3 / 2, arg2
						+ arg4 / 2);
				te[arg0] = false;
			}
			arg1 -= gameImage.textWidth(arg5, arg6) / 2;
		}
		if (currentFocusHandle == arg0) {
			arg5 = arg5 + "*";
		}
		int k = arg2 + gameImage.messageFontHeight(arg6) / 3;
		drawTextWithMask(arg0, arg1, k, arg5, arg6);
	}

	public void ed(int arg0, int arg1, int arg2, int arg3) {
		gameImage.setDimensions(arg0, arg1, arg0 + arg2, arg1 + arg3);
		gameImage.ag(arg0, arg1, arg2, arg3, COLOUR_BOX_BORDER2, COLOUR_BOX_GRADIENT_TOP);
		if (dg) {
			for (int j = arg0 - (arg1 & 0x3f); j < arg0 + arg2; j += 128) {
				for (int k = arg1 - (arg1 & 0x1f); k < arg1 + arg3; k += 128) {
					gameImage.vf(j, k, 6 + eg);
				}

			}
		}
		
		gameImage.drawLineX(arg0, arg1, arg2, COLOUR_BOX_GRADIENT_TOP);
		gameImage.drawLineX(arg0 + 1, arg1 + 1, arg2 - 2, COLOUR_BOX_GRADIENT_TOP);
		gameImage.drawLineX(arg0 + 2, arg1 + 2, arg2 - 4, COLOUR_BOX_GRADIENT_BOTTOM);
		gameImage.drawLineY(arg0, arg1, arg3, COLOUR_BOX_GRADIENT_TOP);
		gameImage.drawLineY(arg0 + 1, arg1 + 1, arg3 - 2, COLOUR_BOX_GRADIENT_TOP);
		gameImage.drawLineY(arg0 + 2, arg1 + 2, arg3 - 4, COLOUR_BOX_GRADIENT_BOTTOM);
		gameImage.drawLineX(arg0, (arg1 + arg3) - 1, arg2, COLOUR_BOX_BORDER2);
		gameImage.drawLineX(arg0 + 1, (arg1 + arg3) - 2, arg2 - 2, COLOUR_BOX_BORDER2);
		gameImage.drawLineX(arg0 + 2, (arg1 + arg3) - 3, arg2 - 4, COLOUR_BOX_BORDER1);
		gameImage.drawLineY((arg0 + arg2) - 1, arg1, arg3, COLOUR_BOX_BORDER2);
		gameImage.drawLineY((arg0 + arg2) - 2, arg1 + 1, arg3 - 2, COLOUR_BOX_BORDER2);
		gameImage.drawLineY((arg0 + arg2) - 3, arg1 + 2, arg3 - 4, COLOUR_BOX_BORDER1);
		gameImage.resetDimensions();
	}

	public void cd(int arg0, int arg1, int arg2, int arg3) {
		gameImage.drawBox(arg0, arg1, arg2, arg3, 0);
		gameImage.drawBoxEdge(arg0, arg1, arg2, arg3, jagexColorGrayBlue);
		gameImage.drawBoxEdge(arg0 + 1, arg1 + 1, arg2 - 2, arg3 - 2, jagexColorGrayTeal);
		gameImage.drawBoxEdge(arg0 + 2, arg1 + 2, arg2 - 4, arg3 - 4, jagexColorDarkPurple);
		gameImage.drawPicutre(arg0, arg1, 2 + eg);
		gameImage.drawPicutre((arg0 + arg2) - 7, arg1, 3 + eg);
		gameImage.drawPicutre(arg0, (arg1 + arg3) - 7, 4 + eg);
		gameImage.drawPicutre((arg0 + arg2) - 7, (arg1 + arg3) - 7, 5 + eg);
	}

	protected void wc(int arg0, int arg1, int arg2) {
		gameImage.drawPicutre(arg0, arg1, arg2);
	}

	protected void sc(int arg0, int arg1, int arg2) {
		gameImage.drawLineX(arg0, arg1, arg2, 0);
	}

	protected void zc(int arg0, int arg1, int arg2, int arg3, int arg4,
			int arg5, String arg6[], int arg7, int arg8) {
		int j = arg4 / gameImage.messageFontHeight(arg5);
		if (arg8 > arg7 - j) {
			arg8 = arg7 - j;
		}
		if (arg8 < 0) {
			arg8 = 0;
		}
		ue[arg0] = arg8;
		if (j < arg7) {
			int k = (arg1 + arg3) - 12;
			int i1 = ((arg4 - 27) * j) / arg7;
			if (i1 < 6) {
				i1 = 6;
			}
			int k1 = ((arg4 - 27 - i1) * arg8) / (arg7 - j);
			if (lf == 1 && mouseX >= k && mouseX <= k + 12) {
				if (mouseY > arg2 && mouseY < arg2 + 12 && arg8 > 0) {
					arg8--;
				}
				if (mouseY > (arg2 + arg4) - 12 && mouseY < arg2 + arg4
						&& arg8 < arg7 - j) {
					arg8++;
				}
				ue[arg0] = arg8;
				te[arg0] = true;
			}
			if (lf == 1
					&& (mouseX >= k && mouseX <= k + 12 || mouseX >= k - 12
							&& mouseX <= k + 24 && qe[arg0])) {
				if (mouseY > arg2 + 12 && mouseY < (arg2 + arg4) - 12) {
					qe[arg0] = true;
					int i2 = mouseY - arg2 - 12 - i1 / 2;
					arg8 = (i2 * arg7) / (arg4 - 24);
					if (arg8 > arg7 - j) {
						arg8 = arg7 - j;
					}
					if (arg8 < 0) {
						arg8 = 0;
					}
					ue[arg0] = arg8;
					te[arg0] = true;
				}
			} else {
				qe[arg0] = false;
			}
			if (te[arg0]) {
				tc(arg1, arg2, arg1 + arg3, arg2 + arg4);
				te[arg0] = false;
			}
			k1 = ((arg4 - 27 - i1) * arg8) / (arg7 - j);
			jd(arg1, arg2, arg3, arg4, k1, i1);
		}
		if (te[arg0]) {
			tc(arg1, arg2, arg1 + arg3, arg2 + arg4);
			te[arg0] = false;
		}
		int l = arg4 - j * gameImage.messageFontHeight(arg5);
		int j1 = arg2 + (gameImage.messageFontHeight(arg5) * 5) / 6 + l / 2;
		for (int l1 = arg8; l1 < arg7; l1++) {
			drawTextWithMask(arg0, arg1 + 2, j1, arg6[l1], arg5);
			j1 += gameImage.messageFontHeight(arg5) - ig;
			if (j1 >= arg2 + arg4) {
				return;
			}
		}

	}

	protected void jd(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) {
		int j = (arg0 + arg2) - 12;
		gameImage.drawBoxEdge(j, arg1, 12, arg3, 0);
		gameImage.drawPicutre(j + 1, arg1 + 1, eg);
		gameImage.drawPicutre(j + 1, (arg1 + arg3) - 12, 1 + eg);
		gameImage.drawLineX(j, arg1 + 13, 12, 0);
		gameImage.drawLineX(j, (arg1 + arg3) - 13, 12, 0);
		gameImage.ag(j + 1, arg1 + 14, 11, arg3 - 27, jagexColorPink, jagexColorDarkBlue);
		gameImage.drawBox(j + 3, arg4 + arg1 + 14, 7, arg5, jagexColorTealBlue);
		gameImage.drawLineY(j + 2, arg4 + arg1 + 14, arg5, jagexColorWhiteBlue);
		gameImage.drawLineY(j + 2 + 8, arg4 + arg1 + 14, arg5, jagexColorDarkGreen);
	}

	protected void mc(int arg0, int arg1, int arg2, int arg3, String arg4[]) {
		int j = 0;
		int k = arg4.length;
		for (int l = 0; l < k; l++) {
			j += gameImage.textWidth(arg4[l], arg3);
			if (l < k - 1) {
				j += gameImage.textWidth("  ", arg3);
			}
		}

		int i1 = arg1 - j / 2;
		int j1 = arg2 + gameImage.messageFontHeight(arg3) / 3;
		for (int k1 = 0; k1 < k; k1++) {
			int l1;
			if (menuObjectColourMask[arg0]) {
				l1 = 0xffffff;
			} else {
				l1 = 0;
			}
			if (mouseX >= i1 && mouseX <= i1 + gameImage.textWidth(arg4[k1], arg3)
					&& mouseY <= j1 && mouseY > j1 - gameImage.messageFontHeight(arg3)) {
				if (menuObjectColourMask[arg0]) {
					l1 = 0x808080;
				} else {
					l1 = 0xffffff;
				}
				if (lastMouseButton == 1) {
					we[arg0] = k1;
					se[arg0] = true;
				}
			}
			if (we[arg0] == k1) {
				if (menuObjectColourMask[arg0]) {
					l1 = 0xff0000;
				} else {
					l1 = 0xc00000;
				}
			}
			gameImage.drawString(arg4[k1], i1, j1, arg3, l1);
			i1 += gameImage.textWidth(arg4[k1] + "  ", arg3);
		}

	}

	protected void zb(int arg0, int arg1, int arg2, int arg3, String arg4[]) {
		int j = arg4.length;
		int k = arg2 - (gameImage.messageFontHeight(arg3) * (j - 1)) / 2;
		for (int l = 0; l < j; l++) {
			int i1;
			if (menuObjectColourMask[arg0]) {
				i1 = 0xffffff;
			} else {
				i1 = 0;
			}
			int j1 = gameImage.textWidth(arg4[l], arg3);
			if (mouseX >= arg1 - j1 / 2 && mouseX <= arg1 + j1 / 2
					&& mouseY - 2 <= k && mouseY - 2 > k - gameImage.messageFontHeight(arg3)) {
				if (menuObjectColourMask[arg0]) {
					i1 = 0x808080;
				} else {
					i1 = 0xffffff;
				}
				if (lastMouseButton == 1) {
					we[arg0] = l;
					se[arg0] = true;
				}
			}
			if (we[arg0] == l) {
				if (menuObjectColourMask[arg0]) {
					i1 = 0xff0000;
				} else {
					i1 = 0xc00000;
				}
			}
			gameImage.drawString(arg4[l], arg1 - j1 / 2, k, arg3, i1);
			k += gameImage.messageFontHeight(arg3);
		}

	}

	protected void dc(int arg0, int arg1, int arg2, int arg3, int arg4,
			int arg5, String arg6[], int arg7, int arg8) {
		int j = arg4 / gameImage.messageFontHeight(arg5);
		if (j < arg7) {
			int k = (arg1 + arg3) - 12;
			int i1 = ((arg4 - 27) * j) / arg7;
			if (i1 < 6) {
				i1 = 6;
			}
			int k1 = ((arg4 - 27 - i1) * arg8) / (arg7 - j);
			if (lf == 1 && mouseX >= k && mouseX <= k + 12) {
				if (mouseY > arg2 && mouseY < arg2 + 12 && arg8 > 0) {
					arg8--;
				}
				if (mouseY > (arg2 + arg4) - 12 && mouseY < arg2 + arg4
						&& arg8 < arg7 - j) {
					arg8++;
				}
				ue[arg0] = arg8;
				te[arg0] = true;
			}
			if (lf == 1
					&& (mouseX >= k && mouseX <= k + 12 || mouseX >= k - 12
							&& mouseX <= k + 24 && qe[arg0])) {
				if (mouseY > arg2 + 12 && mouseY < (arg2 + arg4) - 12) {
					qe[arg0] = true;
					int i2 = mouseY - arg2 - 12 - i1 / 2;
					arg8 = (i2 * arg7) / (arg4 - 24);
					if (arg8 < 0) {
						arg8 = 0;
					}
					if (arg8 > arg7 - j) {
						arg8 = arg7 - j;
					}
					ue[arg0] = arg8;
					te[arg0] = true;
				}
			} else {
				qe[arg0] = false;
			}
			if (te[arg0]) {
				tc(arg1, arg2, arg1 + arg3, arg2 + arg4);
				te[arg0] = false;
			}
			k1 = ((arg4 - 27 - i1) * arg8) / (arg7 - j);
			jd(arg1, arg2, arg3, arg4, k1, i1);
		} else {
			arg8 = 0;
			ue[arg0] = 0;
		}
		if (te[arg0]) {
			tc(arg1, arg2, arg1 + arg3, arg2 + arg4);
			te[arg0] = false;
		}
		xe[arg0] = -1;
		int l = arg4 - j * gameImage.messageFontHeight(arg5);
		int j1 = arg2 + (gameImage.messageFontHeight(arg5) * 5) / 6 + l / 2;
		for (int l1 = arg8; l1 < arg7; l1++) {
			int j2;
			if (menuObjectColourMask[arg0]) {
				j2 = 0xffffff;
			} else {
				j2 = 0;
			}
			if (mouseX >= arg1 + 2
					&& mouseX <= arg1 + 2 + gameImage.textWidth(arg6[l1], arg5)
					&& mouseY - 2 <= j1 && mouseY - 2 > j1 - gameImage.messageFontHeight(arg5)) {
				if (menuObjectColourMask[arg0]) {
					j2 = 0x808080;
				} else {
					j2 = 0xffffff;
				}
				xe[arg0] = l1;
				if (lastMouseButton == 1) {
					we[arg0] = l1;
					se[arg0] = true;
				}
			}
			if (we[arg0] == l1 && bg) {
				j2 = 0xff0000;
			}
			gameImage.drawString(arg6[l1], arg1 + 2, j1, arg5, j2);
			j1 += gameImage.messageFontHeight(arg5);
			if (j1 >= arg2 + arg4) {
				return;
			}
		}

	}

	/*
	 * Draws Text 
	 * Starts at X and Y Coord
	 * Need to find out what type and the boolean are for.
	 */
	public int drawText(int x, int y, String text, int type, boolean arg4) {
		menuObjectType[menuObjectCount] = 1;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = type;
		menuObjectColourMask[menuObjectCount] = arg4;
		menuObjectX[menuObjectCount] = x;
		menuObjectY[menuObjectCount] = y;
		menuObjectText[menuObjectCount] = text;
		return menuObjectCount++;
	}

	public void updateText(int arg0, String arg1) {
		menuObjectText[arg0] = arg1;
		te[arg0] = true;
	}

	public String getText(int arg0) {
		if (menuObjectText[arg0] == null) {
			return "null";
		} else {
			return menuObjectText[arg0];
		}
	}

	public int yc(int arg0, int arg1, int arg2, int arg3) {
		menuObjectType[menuObjectCount] = 2;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0 - arg2 / 2;
		menuObjectY[menuObjectCount] = arg1 - arg3 / 2;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		return menuObjectCount++;
	}

	public int gc(int arg0, int arg1, int arg2, int arg3) {
		menuObjectType[menuObjectCount] = 11;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		return menuObjectCount++;
	}

	public int ic(int arg0, int arg1, int arg2, int arg3) {
		menuObjectType[menuObjectCount] = 11;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0 - arg2 / 2;
		menuObjectY[menuObjectCount] = arg1 - arg3 / 2;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		return menuObjectCount++;
	}

	public int jc(int arg0, int arg1, int arg2) {
		int j = gameImage.fk[arg2];
		int k = gameImage.gk[arg2];
		menuObjectType[menuObjectCount] = 12;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0 - j / 2;
		menuObjectY[menuObjectCount] = arg1 - k / 2;
		menuObjectWidth[menuObjectCount] = j;
		menuObjectHeight[menuObjectCount] = k;
		menuObjectTextType[menuObjectCount] = arg2;
		return menuObjectCount++;
	}

	public int bc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
			boolean arg6) {
		menuObjectType[menuObjectCount] = 4;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		menuObjectColourMask[menuObjectCount] = arg6;
		menuObjectTextType[menuObjectCount] = arg4;
		handleMaxTextLength[menuObjectCount] = arg5;
		menuListTextCount[menuObjectCount] = 0;
		ue[menuObjectCount] = 0;
		menuListText[menuObjectCount] = new String[arg5];
		return menuObjectCount++;
	}

	public void ec(int arg0, String arg1, boolean arg2) {
		int j = menuListTextCount[arg0]++;
		if (j >= handleMaxTextLength[arg0]) {
			j--;
			menuListTextCount[arg0]--;
			for (int k = 0; k < j; k++) {
				menuListText[arg0][k] = menuListText[arg0][k + 1];
			}

		}
		menuListText[arg0][j] = arg1;
		if (arg2) {
			ue[arg0] = 0xf423f;
		}
		te[arg0] = true;
	}

	public int cc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
			boolean arg6, boolean arg7) {
		menuObjectType[menuObjectCount] = 5;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		re[menuObjectCount] = arg6;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = arg4;
		menuObjectColourMask[menuObjectCount] = arg7;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		handleMaxTextLength[menuObjectCount] = arg5;
		menuObjectText[menuObjectCount] = "";
		return menuObjectCount++;
	}

	public int vc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
			boolean arg6, boolean arg7) {
		menuObjectType[menuObjectCount] = 6;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		re[menuObjectCount] = arg6;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = arg4;
		menuObjectColourMask[menuObjectCount] = arg7;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		handleMaxTextLength[menuObjectCount] = arg5;
		menuObjectText[menuObjectCount] = "";
		return menuObjectCount++;
	}

	public int qc(int arg0, int arg1, String arg2[], int arg3, boolean arg4) {
		menuObjectType[menuObjectCount] = 7;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = arg3;
		menuObjectColourMask[menuObjectCount] = arg4;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuListText[menuObjectCount] = arg2;
		we[menuObjectCount] = 0;
		return menuObjectCount++;
	}

	public int ac(int arg0, int arg1, String arg2[], int arg3, boolean arg4) {
		menuObjectType[menuObjectCount] = 8;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = arg3;
		menuObjectColourMask[menuObjectCount] = arg4;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuListText[menuObjectCount] = arg2;
		we[menuObjectCount] = 0;
		return menuObjectCount++;
	}

	public int nc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
			boolean arg6) {
		menuObjectType[menuObjectCount] = 9;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectTextType[menuObjectCount] = arg4;
		menuObjectColourMask[menuObjectCount] = arg6;
		menuObjectX[menuObjectCount] = arg0;
		menuObjectY[menuObjectCount] = arg1;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		handleMaxTextLength[menuObjectCount] = arg5;
		menuListText[menuObjectCount] = new String[arg5];
		menuListTextCount[menuObjectCount] = 0;
		ue[menuObjectCount] = 0;
		we[menuObjectCount] = -1;
		xe[menuObjectCount] = -1;
		return menuObjectCount++;
	}

	public void kc(int arg0) {
		menuListTextCount[arg0] = 0;
		te[arg0] = true;
	}

	public void xc(int arg0) {
		ue[arg0] = 0;
		xe[arg0] = -1;
	}

	public void ad(int arg0, int arg1, String arg2) {
		menuListText[arg0][arg1] = arg2;
		if (arg1 + 1 > menuListTextCount[arg0]) {
			menuListTextCount[arg0] = arg1 + 1;
		}
		te[arg0] = true;
	}

	public int id(int arg0, int arg1, int arg2, int arg3) {
		menuObjectType[menuObjectCount] = 10;
		menuObjectCanAcceptActions[menuObjectCount] = true;
		se[menuObjectCount] = false;
		menuObjectX[menuObjectCount] = arg0 - arg2 / 2;
		menuObjectY[menuObjectCount] = arg1 - arg3 / 2;
		menuObjectWidth[menuObjectCount] = arg2;
		menuObjectHeight[menuObjectCount] = arg3;
		return menuObjectCount++;
	}

	protected GameImage gameImage;
	int menuObjectCount;
	int oe;
	boolean menuObjectCanAcceptActions[];
	boolean qe[];
	boolean re[];
	boolean se[];
	boolean te[];
	public int ue[];
	public int menuListTextCount[];
	public int we[];
	public int xe[];
	boolean menuObjectColourMask[];
	int menuObjectX[];
	int menuObjectY[];
	int menuObjectType[];
	int menuObjectWidth[];
	int menuObjectHeight[];
	int handleMaxTextLength[];
	int menuObjectTextType[];
	String menuObjectText[];
	String menuListText[][];
	int mouseX;
	int mouseY;
	int lastMouseButton;
	int lf;
	int currentFocusHandle;
	int nf;
	int of;
	int jagexColorPink;
	int jagexColorDarkBlue;
	int jagexColorWhiteBlue;
	int jagexColorTealBlue;
	int jagexColorDarkGreen;
	int jagexColorGrayBlue;
	int jagexColorGrayTeal;
	int jagexColorDarkPurple;
	int COLOUR_BOX_GRADIENT_TOP;
	int COLOUR_BOX_GRADIENT_BOTTOM;
	int COLOUR_BOX_BORDER1;
	int COLOUR_BOX_BORDER2;
	public boolean bg;
	public static boolean cg;
	public static boolean dg = true;
	public static int eg;
	public static int redModifier = 114;
	public static int greenModifier = 114;
	public static int blueModifier = 176;
	public static int ig;

}
